home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Tools&Utilities / MathPad 2.4 / Examples / incl / complex ops next >
Text File  |  1995-04-30  |  636b  |  13 lines

  1. ------ utility functions for complex numbers ------
  2. -- Arrays can be used to represent complex numbers. Addition, subtraction and multiplication by a real can be done directly. The following functions implement other basic operations on complex numbers.
  3.  
  4. Creal(r) = {r,0}  -- create a complex from a real
  5. Cabs(A) = sqrt(A[1]^2+A[2]^2)
  6. Cmult(A,B) = {A[1]*B[1]-A[2]*B[2],A[2]*B[1]+A[1]*B[2]}
  7. Csqr(A) = {A[1]*A[1]-A[2]*A[2],2*A[1]*A[2]}
  8. Ccube(A) = Cmult(A,Csqr(A))
  9. Cdiv(A,B)={(B[1]*A[1]+B[2]*A[2])/(B[1]^2+B[2]^2),
  10.          (B[1]*A[2]-B[2]*A[1])/(B[1]^2+B[2]^2)}
  11. Conj(A) = {A[1],-A[2]}
  12. Carg(A) = 0 when A[1]=0 and A[2]=0, atan2(A[2],A[1])
  13.